using System;
using System.Threading;
using System.Collections;
using System.Text;
using System.Net;
using System.Net.Sockets;
using XYThreadPoolLib;
using System.Diagnostics;

namespace CommLayer
{
    class TcpIpClientMedialon : TcpIpClient
    {
        byte m_suffix, m_prefix;
        

        public TcpIpClientMedialon( String sRemoteAddress, int nRemotePort,byte preffix, byte suffix,ConnectionFilterDelegate delegateConnectionFilter,
                        StringInputHandlerDelegate delegateStringInputHandler,
                        ExceptionHandlerDelegate delegateExceptionHandler)
            : base(sRemoteAddress, nRemotePort, delegateConnectionFilter, delegateStringInputHandler, delegateExceptionHandler)
        {
           m_suffix = suffix;
           m_prefix = preffix;
          
               
        }

        
        /// <summary>
        /// send string data preceeded by a prefix, ended by suffix
        /// </summary>
        /// <param name="sData"></param>
        /// <returns></returns>
		public override bool SendStringData(String sData)
		{
			Byte[] pData = new Byte[sData.Length+2];
			pData[0] = m_prefix;
			pData[pData.Length-1] = m_suffix;
            int len = sData.Length;
            for (int i = 1; i <= sData.Length; i++)
                pData[i] = (byte)sData[i-1];
			
			return SendRawData(pData);
        }

    }
}
